package com.hjs.homework.word_count

import org.apache.flink.api.scala._

object WordCountScala {
  def main(args: Array[String]): Unit = {
    val inputPath = "D:\\Homework\\hello.txt"
    val outputPath = "D:\\Homework\\scalaOutput"

    val env = ExecutionEnvironment.getExecutionEnvironment

    val data = env.readTextFile(inputPath)

    val out = data.flatMap(_.split(" ")).map((_, 1)).groupBy(0).sum(1)

    out.writeAsCsv(outputPath,"\n","\t").setParallelism(1)

    env.execute
  }
}
